package JUnit;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import crypt.CryptAES;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
 * @version 1.0
 * @author Jonas Untiet
 *
 */
public class CryptAESTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
		public void testCryptAES() throws IOException{

			ByteArrayOutputStream test = new ByteArrayOutputStream();
			DataOutputStream out = new DataOutputStream(test);
			out.write( 'H' ); out.write( 'A' ); out.write( 'L' ); out.write( 'L' ); out.write( 'O' );
			out.close();
			byte[] data = test.toByteArray();
			
			CryptAES aes = CryptAES.getInstance();
			byte[] verschluesselt = aes.encrypt(data);
			byte[] entschluesselt = aes.decrypt(verschluesselt, aes.getSymmetricKey());
			
			assertArrayEquals(data, entschluesselt);
			assertArrayEquals("Hallo",data,entschluesselt);
	}
		
		
	}


